apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  labels:
    prometheus: k8s-system
  name: k8s-system
  namespace: kubesphere-monitoring-system
spec:
  affinity:
    nodeAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - preference:
          matchExpressions:
          - key: node-role.kubernetes.io/monitoring
            operator: Exists
        weight: 100
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: prometheus
              operator: In
              values:
              - k8s-system
          namespaces:
          - kubesphere-monitoring-system
          topologyKey: kubernetes.io/hostname
        weight: 100
  additionalScrapeConfigs:
    key: prometheus-additional.yaml
    name: additional-scrape-configs
  imagePullSecrets:
  - name: qingcloud 
  baseImage: {{ prometheus_repo }}
  nodeSelector:
    beta.kubernetes.io/os: linux
  query:
    maxConcurrency: 1000
  replicas: {{ monitoring.prometheusReplicas }}
  resources:
    limits:
      cpu: "2.5"
      memory: 2Gi
    requests:
      cpu: 10m
      memory: {{ monitoring.prometheusMemoryRequest }}
  retention: 7d
  ruleSelector:
    matchLabels:
      prometheus: k8s
      role: alert-rules
  scrapeInterval: 1m
{% if etcd.monitoring is defined and etcd.monitoring == true %}
  secrets:
  - kube-etcd-client-certs
{% endif %}
  securityContext:
    fsGroup: 0
    runAsNonRoot: false
    runAsUser: 0
  serviceAccountName: prometheus-k8s
  serviceMonitorNamespaceSelector: {}
  serviceMonitorSelector:
    matchExpressions:
    - key: k8s-app
      operator: In
      values:
{% if etcd.monitoring is defined and etcd.monitoring == true %}
      - etcd
{% endif %}
      - coredns
      - apiserver
      - prometheus
      - kube-scheduler
      - kube-controller-manager
  storage:
    volumeClaimTemplate:
      spec:
{% if persistence.storageClass is defined and persistence.storageClass != "" %}
        storageClassName: {{ persistence.storageClass }}
{% endif %}
        resources:
          requests:
            storage: {{ monitoring.prometheusVolumeSize }}

  tolerations:
  - effect: NoSchedule
    key: dedicated
    operator: Equal
    value: monitoring
  version: {{ prometheus_tag }}
